package com.example.singing.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 比赛模型类
 */
public class Competition implements Serializable {
    private String id;
    private String name;
    private String date;
    private String level;
    private String scoringRule;
    private List<String> teamIds; // 参赛队伍ID列表
    private String backgroundImagePath; // 背景图片路径

    public Competition(String id, String name, String date, String level, String scoringRule) {
        this.id = id;
        this.name = name;
        this.date = date;
        this.level = level;
        this.scoringRule = scoringRule;
        this.teamIds = new ArrayList<>();
        this.backgroundImagePath = null; // 默认无自定义背景图片
    }

    // Getters and Setters
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }

    public String getName() { return name; }
    public void setName(String name) { this.name = name; }

    public String getDate() { return date; }
    public void setDate(String date) { this.date = date; }

    public String getLevel() { return level; }
    public void setLevel(String level) { this.level = level; }

    public String getScoringRule() { return scoringRule; }
    public void setScoringRule(String scoringRule) { this.scoringRule = scoringRule; }

    public List<String> getTeamIds() { return teamIds; }
    public void setTeamIds(List<String> teamIds) { this.teamIds = teamIds; }

    public String getBackgroundImagePath() { return backgroundImagePath; }
    public void setBackgroundImagePath(String backgroundImagePath) { this.backgroundImagePath = backgroundImagePath; }

    public void addTeam(String teamId) {
        if (!teamIds.contains(teamId)) {
            teamIds.add(teamId);
        }
    }

    public void removeTeam(String teamId) {
        teamIds.remove(teamId);
    }

    @Override
    public String toString() {
        return name + " (" + level + ")";
    }
}